﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;
using System.Text.RegularExpressions;
namespace Sunboxsoft.ASMS.Client.UI.Common.Validations
{
    /// <summary>
    /// 只能输入非负浮点数,最多只能输入3位小数
    /// </summary>
    public class TextEditIsFloatNumber : TextEditRegexValidation
    {

        public TextEditIsFloatNumber(TextEdit textEdit, string strMess, bool isRequired)
            : base(textEdit, @"^(([0-9]{1,})|([0-9]{1,}\.[0-9]{1,3}))$", strMess, isRequired)
        {

        }
        public override bool ValueChanging(string newValue)
        {
            if (string.IsNullOrEmpty(newValue))
            {
                return true;
            }
            else
            {
                Regex regex = new Regex(@"^[0-9][\d\.\d]*$");
                if (regex.IsMatch(newValue))
                {
                    return true;
                }
                return false;
            }
        }
    }
}
